package com.edu.study.base.StuTestScoreLevel.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.study.base.StuTestScoreLevel.domain.StuTestScoreLevel;
import com.edu.study.base.StuTestScoreLevel.service.IStuTestScoreLevelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生能力测试得分对应等级关系Controller
 * 
 * @author zw
 * @date 2021-08-05
 */
@RestController
@RequestMapping("/StuTestScoreLevel/scoreLevel")
public class StuTestScoreLevelController extends BaseController
{
    @Autowired
    private IStuTestScoreLevelService stuTestScoreLevelService;

    /**
     * 查询学生能力测试得分对应等级关系列表
     */
    @PreAuthorize("@ss.hasPermi('StuTestScoreLevel:scoreLevel:list')")
    @GetMapping("/list")
    public TableDataInfo list(StuTestScoreLevel stuTestScoreLevel)
    {
        startPage();
        List<StuTestScoreLevel> list = stuTestScoreLevelService.selectStuTestScoreLevelList(stuTestScoreLevel);
        return getDataTable(list);
    }

    /**
     * 导出学生能力测试得分对应等级关系列表
     */
    @PreAuthorize("@ss.hasPermi('StuTestScoreLevel:scoreLevel:export')")
    @Log(title = "学生能力测试得分对应等级关系", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StuTestScoreLevel stuTestScoreLevel)
    {
        List<StuTestScoreLevel> list = stuTestScoreLevelService.selectStuTestScoreLevelList(stuTestScoreLevel);
        ExcelUtil<StuTestScoreLevel> util = new ExcelUtil<StuTestScoreLevel>(StuTestScoreLevel.class);
        return util.exportExcel(list, "scoreLevel");
    }

    /**
     * 获取学生能力测试得分对应等级关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('StuTestScoreLevel:scoreLevel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(stuTestScoreLevelService.selectStuTestScoreLevelById(id));
    }

    /**
     * 新增学生能力测试得分对应等级关系
     */
    @PreAuthorize("@ss.hasPermi('StuTestScoreLevel:scoreLevel:add')")
    @Log(title = "学生能力测试得分对应等级关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StuTestScoreLevel stuTestScoreLevel)
    {
        return toAjax(stuTestScoreLevelService.insertStuTestScoreLevel(stuTestScoreLevel));
    }

    /**
     * 修改学生能力测试得分对应等级关系
     */
    @PreAuthorize("@ss.hasPermi('StuTestScoreLevel:scoreLevel:edit')")
    @Log(title = "学生能力测试得分对应等级关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StuTestScoreLevel stuTestScoreLevel)
    {
        return toAjax(stuTestScoreLevelService.updateStuTestScoreLevel(stuTestScoreLevel));
    }

    /**
     * 删除学生能力测试得分对应等级关系
     */
    @PreAuthorize("@ss.hasPermi('StuTestScoreLevel:scoreLevel:remove')")
    @Log(title = "学生能力测试得分对应等级关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stuTestScoreLevelService.deleteStuTestScoreLevelByIds(ids));
    }
}
